package com.zbaohuang.activity;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;

import com.joanzapata.android.BaseAdapterHelper;
import com.joanzapata.android.QuickAdapter;
import com.zbaohuang.fragment.CommentModel;
import com.zbaohuang.xyh.R;

import java.util.ArrayList;
import java.util.List;

public class VolunteerActivity extends BaseActivity {

    List<CommentModel> commentModels;
    QuickAdapter<CommentModel> quickAdapter;

    ListView listView;
    View headerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_volunteer);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        listView = (ListView)findViewById(R.id.listview);

        headerView = LayoutInflater.from(this).inflate(R.layout.header_detail_volunteer,null,false);
        listView.addHeaderView(headerView);

        commentModels = new ArrayList<CommentModel>();
        commentModels.add(new CommentModel(0));
        commentModels.add(new CommentModel(1));
        commentModels.add(new CommentModel(2));

        quickAdapter = new QuickAdapter<CommentModel>(this,R.layout.item_comment) {
            @Override
            protected void convert(BaseAdapterHelper helper, CommentModel item) {
                if (item.getPos() == 0){
                    helper.setImageResource(R.id.avatarImageView,R.mipmap.avatar1);
                    helper.setText(R.id.nameTextView, "黄飞瑟");
                    helper.setText(R.id.datetimeTextView, "2016-04-07 12:01");
                    helper.setText(R.id.contentTextView,"范老师真的是一个非常好的义工，很会逗老人的开心，我父母时间相信你，期待能有机会再来我家一次；");
                } else if(item.getPos() == 1){
                    helper.setImageResource(R.id.avatarImageView,R.mipmap.avatar2);
                    helper.setText(R.id.nameTextView,"李朋");
                    helper.setText(R.id.datetimeTextView,"2016-04-05 16:11");
                    helper.setText(R.id.contentTextView,"范老师，我父母非常的喜欢你，自从你上次来探访我家父母一次后，我家的二老总是跟我提起你，也期盼着你能有机会可以再次去看望他们老人家");

                } else if(item.getPos() == 2){
                    helper.setImageResource(R.id.avatarImageView,R.mipmap.avatar2);
                    helper.setText(R.id.nameTextView,"陈白");
                    helper.setText(R.id.datetimeTextView,"2016-04-05 10:11");
                    helper.setText(R.id.contentTextView,"范老师，你用行动向我展现的如何关爱父母，关心父母，你是我的榜样");

                }
            }
        };
        listView.setAdapter(quickAdapter);
        quickAdapter.addAll(commentModels);

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        if (item.getItemId() == android.R.id.home){
            onBackPressed();
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

}
